Network FKPP Prior and Posterior Predictive

In this notebook I will look at the prior and posterior predictive generative models for a Network FKPP model.

 Environment

First, document the environment and load necesary packages

Building the Network and Model

As with the diffusion model, the first step will be to construct a random network using LightGraphs.

After this, we can define the Network FKPP equation:

$\frac{d\mathbf{p}_i}{dt} = -k \sum\limits_{j=1}^{N}\mathbf{L}_{ij}^{\omega}\mathbf{p}_j + \alpha \mathbf{p}_i\left(1-\mathbf{p}_i\right)$"

Solving the model for N = 5

We can now solve the model for the network defined with five nodes. We do this using DifferentialEquations, using an adaptive step size numerical method.

We start by making a graph Erdos-Renyi random graph with connection probability of 0.5.

Then we can set initial conditions to initialise the ODEProblem and numerically solve.

Next, we'll discretise this solution and add noise to simulate synethic data.

 Generative model and sampling from the prior

Now that we have a model and some synthetic data, we can create a generative model in Turing that aims to capture the data probablistically. In our case, the generative model is defined for data:

$$ \mathbf{y} = f(\mathbf{u0}, \rho) + \mathcal{N}(0, \sigma) $$$$ \sigma = 0.02 $$

Our probablistic represention of these model parameters are given by:

$$\sigma \approx \Gamma^{-1}(2, 3)$$

$$\kappa \approx \mathcal{N}(5,10,[0,10])$$ $$\alpha \approx \mathcal{N}(5,10,[0,10])$$ $$\mathbf{u0} \approx \mathcal{N}(0,2,[0,1])$$

The above plots show that the prior may not be well defined for our data. For the most part, the prior predictive simulations are left shifted. This is likely due to the prior placed on the diffusion and growth constants, i.e.:

$$\kappa \approx \mathcal{N}(5,10,[0,10])$$$$\alpha \approx \mathcal{N}(5,10,[0,10])$$

Let's plot this distibution to see how wide it is.

The distribution is relatively flat around the mean and betweent the bounds, as desired. The results above are almost certainly due to the true values not being close to the median of the distibution and therefore there is a greater chance of higher values, shifting the dynamics to the left.

 Posterior Predictive

Next, let's try sampling from the posterior using NUTS to see if the generative model is able to capture the dynamics of the data given our model.